cc.Class({
    extends: cc.Component,

    properties: {
        message: {
            default: null,
            type: cc.Node
        }

        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
    },

    // use this for initialization
    onLoad: function() {
        //一开始就出来了，只不过放在外面，要用时移进来
    },
    show: function(message, callback) {
        let self=this;
        cc.log('message:'+message);
        this.message.getComponent(cc.Label).string = message;
        var finished = cc.callFunc(function(target, ind) {
            if (callback) {
                callback.call();
            }
        }, this, 1);
        var finished1=cc.callFunc(function(target, ind) {
            self.node.destroy();
           }, this, 1); 
        //var seq = cc.sequence(cc.hide(), cc.moveTo(0, cc.p(0, 0)), cc.fadeIn(1), finished, cc.fadeOut(3));
         var seq = cc.sequence( cc.moveTo(0, cc.p(0, 0)), cc.fadeIn(1), finished, cc.fadeOut(3),finished1);
        this.node.runAction(seq);
    },
    // _show:function(message,callback,fadein_time,fadeout_time){
    //     this.message.getComponent(cc.Label).string = message;
    //     var finished = cc.callFunc(function(target, ind) {
    //         if (callback) {
    //             callback.call();
    //         }
    //     }, this,1);
    //     var seq = cc.sequence(cc.hide(), cc.moveTo(0, cc.p(0, 0)), cc.fadeIn(fadein_time), finished,cc.fadeOut(fadeout_time));
    //     this.node.runAction(seq);
    // },
    setMessage: function(message) {
        this.message.getComponent(cc.Label).string = message;
    },
    fadein: function(time) {
        this.node.runAction(cc.sequence(cc.hide(), cc.moveTo(0, cc.p(0, 0)), cc.fadeIn(time ? time : 1)));
    },
    fadeout: function(time) {
        this.node.runAction(cc.fadeOut(time ? time : 3));
    },



    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});